package com.work05.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Calendar;

/**
 * @author 绛河
 */
@Controller
public class LoginController {

    @GetMapping("/login")
    public String tologin() {
        return "login";
    }

    /**
     * 获取并封装当前年份跳转到登录页login.html
     * @param model
     * @return
     */
    @GetMapping("/toLoginPage")
    public String toLoginPage(Model model){
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    // 对Security拦截的无权限访问异常处理路径映射
    @GetMapping(value = "/errorPage/{page}")
    public String AccessExecptionHandler(@PathVariable("page") String page) {
        return page;
    }

}
